<?php
require(APPPATH.'libraries/REST_Controller.php');

class Item extends REST_Controller {
	function updated_item_get()
	{
		$day = $this->get('day');
		$array = array();
		$this->load->model('item_model');
		//$this->load->model('inventory_model');
		$this->load->model('category_model');
		$this->load->model('manufacturer_model');
		$this->load->model('promotion_model');
		if($day == null){
			$items = $this->item_model->get_all();
			$category = $this->category_model->get_all();
			$manufacturer = $this->manufacturer_model->get_all();
			$promotion = $this->promotion_model->get_all();
			//$inventory = $this->inventory_model->get_all();
			array_push($array, $items);
			//array_push($array, $inventory);
			array_push($array, $category);
			array_push($array, $manufacturer);
			array_push($array, $promotion);
			if($array)
			{
				$this->response($array, 200); // 200 being the HTTP response code
			}
			else
			{
				$this->response(NULL, 404);
			}
		}
		if (!is_numeric($day)){
			$this->response("day is valid", 403);
		}else{

			$items = $this->item_model->get_updated($day);
			$category = $this->category_model->get_updated($day);
			$manufacturer = $this->manufacturer_model->get_updated($day);
			$promotion = $this->promotion_model->get_updated($day);
			//$inventory = $this->inventory_model->get_updated($day);
			array_push($array, $items);
			//array_push($array, $inventory);
			array_push($array, $category);
			array_push($array, $manufacturer);
			array_push($array, $promotion);

			if($array)
			{
				$this->response($array, 200); // 200 being the HTTP response code
			}
			else
			{
				$this->response(NULL, 404);
			}
		}
	}
}